package com.biejiaogroup.librarymanager.controller;

import com.biejiaogroup.librarymanager.service.BookService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @Author: JesseChan
 * @Date: 2022/5/5
 */
@WebServlet("/deleteBook")
public class DeleteServlet extends HttpServlet {
    private BookService deleteService = new BookService();

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String bookID = request.getParameter("bookID");

        boolean res = deleteService.deleteBook(Integer.parseInt(bookID));

        //返回结果
        PrintWriter out = response.getWriter();
        if(res)
        {
            out.write("success");
        }else {
            out.write("fail");
        }
    }
}
